#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i,n) for(int i=0;i<int(n);++i)

using namespace std;

vector<int> charPos[26];
int vi[26];

string s1,s2;
int ans;
int curPos;

inline void rollBack()
{
    fill(vi,vi+26,0);
    curPos = -1;
    ans++;
}
bool findS1(char c)
{
    int off = c-'a';
    if(charPos[off].empty())
    {
        ans = -1;
        return false;
    }
    else
    {
        while(vi[off]<charPos[off].size()&&charPos[off][vi[off]]<curPos) vi[off]++;
        if(vi[off]==charPos[off].size()) rollBack();
        curPos = charPos[off][vi[off]++];
        return true;
    }
}
int main()
{
    cin>>s1>>s2;
    REP(i,s1.size())
    {
        charPos[s1[i]-'a'].push_back(i);
    }
    ans = 0;
    rollBack();
    REP(i,s2.size())
    {
        if(!findS1(s2[i])) break;
    }
    cout<<ans<<endl;
	return 0;
}
